package com.example.jvmsource.config;

import com.example.jvmsource.entity.MyUser;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description:
 * @author: zhou yu
 * @create: 2021-06-04 09:35
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    @ConditionalOnBean(
            name = "mySon"
    )
    public MyUser myUser(){
        return new MyUser();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LogTraceInterceptor());
    }
}
